#ifndef RESOURCE_MANAGER_H
#define RESOURCE_MANAGER_H

// standard libraries
#include <string>
#include <vector>

// custom libraries
#include "..\include\audio\sound.h"
#include "..\include\file\infile.h"
#include "..\include\graphics\font.h"
#include "..\include\graphics\image.h"

///
/// \class ResourceManager resource_manager.h "include\resource_manager.h"
/// \brief Class used for loading and releasing of resources from memory.
///
/// \details ResourceManager provides an interface through which images, 
/// sounds and other types of resources that could be used by the application 
/// are loaded and released from memory. It keeps track of whether a resource
/// is already loaded, as to not use any more memory to load it again, and 
/// releases it from memory when it is no longer used by the application.
///

class ResourceManager
{
  public:
	static ResourceManager* Instance();

	Font* getFont(const char*, unsigned int);
	Font* getFont(std::string filepath);

	Image* getImage(const char*, unsigned int);
	Image* getImage(std::string filepath);

	Sound* getSound(const char*, unsigned int);
	Sound* getSound(std::string filepath);

	void release(Font*);
	void release(Image*);
	void release(Sound*);

  protected:
	ResourceManager();
	ResourceManager(const ResourceManager&);
	~ResourceManager();
	ResourceManager& operator=(const ResourceManager&);

  private:
	struct FontResource;
	struct ImageResource;
	struct SoundResource;

	std::vector<FontResource*>  fonts_;
	std::vector<ImageResource*> images_;
	std::vector<SoundResource*> sounds_;

	FontResource* createFontResource(const char*, unsigned int);
	FontResource* createFontResource(InFile&, std::string filepath);

	ImageResource* createImageResource(const char*, unsigned int);
	ImageResource* createImageResource(InFile&, std::string filepath);

	SoundResource* createSoundResource(const char*, unsigned int);
	SoundResource* createSoundResource(InFile&, std::string filepath);

	FontResource* findFontResource(const char*, unsigned int);
	FontResource* findFontResource(std::string filepath);

	ImageResource* findImageResource(const char*, unsigned int);
	ImageResource* findImageResource(std::string filepath);

	SoundResource* findSoundResource(const char*, unsigned int);
	SoundResource* findSoundResource(std::string filepath);
};

#endif // RESOURCE_MANAGER_H